package com.qiulingcloud.sys.controller;


import com.qiulingcloud.commonsserver.entity.SysUser;
import com.qiulingcloud.commonsserver.entity.vo.DataResult;
import com.qiulingcloud.commonsserver.entity.vo.PageReqVO;
import com.qiulingcloud.commonsserver.entity.vo.PageVO;
import com.qiulingcloud.sys.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhangqiang
 * @since 2020-04-27
 */
@RestController
@RequestMapping("sysUser")
@Api(tags = "系统管理-用户管理", description = "用户模块相关接口")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @PostMapping("users")
    @ApiOperation(value = "分页+条件查询用户列表")
    public DataResult<PageVO<SysUser>> pageInfo(@RequestBody PageReqVO vo) {
        DataResult result = DataResult.success();
        result.setData(sysUserService.pageInfo(vo));
        return result;
    }

    @GetMapping("userInfo/{userId}")
    @ApiOperation(value = "根据用户id获取用户详细信息")
    public DataResult<SysUser> pageInfo(@PathVariable("userId") String userId) {
        DataResult result = DataResult.success();
        result.setData(sysUserService.getUserByUserId(userId));
        return result;
    }
}

